Skip to content

Split title/description/details and use base-R macros for package Rd#11

Merged
TroyHernandez merged 1 commit into
mainfrom
fix-package-rd
May 19, 2026
Merged

Split title/description/details and use base-R macros for package Rd#11
TroyHernandez merged 1 commit into
mainfrom
fix-package-rd

Conversation

@TroyHernandez

Copy link
Copy Markdown
Contributor

Summary

  • Parser now splits pre-tag content into title (para 1), description (para 2), details (para 3+) on blank lines, matching roxygen2. Previously paragraphs 2+ were jammed into description and \details{} never got populated.
  • generate_package_rd() uses base-R Rd macros (\packageTitle{}, \packageDescription{}, \packageAuthor{}, \packageMaintainer{}, \packageIndices{}) instead of baking content into the Rd file. DESCRIPTION is the source of truth.
  • Hand-written paragraphs after a _PACKAGE block's description now land in \details{} — the slot for design notes, limitations, etc.
  • Drop a now-dead get_maintainer_from_desc() helper.

Triggered by Dirk Eddelbuettel's review of tinyrox 0.3.3 against rspdlite.

Test plan

  • 145 tests pass (was 119; added 26 covering the new parser states and macro template)
  • tinyrox::document(); tinypkgr::install(); tinytest::test_package('tinyrox') clean
  • Against eddelbuettel/rspdlite: man/formatter.Rd is byte-identical to roxygen2's output except for the header comment; man/rspdlite-package.Rd correctly populates \details{} (was missing) and uses macros for title/description/author
  • tools::checkRd() on the regenerated rspdlite-package.Rd returns clean
  • Verified on corteza (an unrelated downstream): no empty \details{} blocks after fresh install

Visible behavior change

For packages with a _PACKAGE block, the generated pkg-package.Rd switches from hardcoded title/description/author to macro-based delegation to DESCRIPTION. Same content if R-file and DESCRIPTION agree; different if they diverge. Also adds a "Package Content" function index (was missing).

Out of scope (separate follow-ups)

  • ##' (legacy two-hash) doc prefix isn't recognized — R/parse.R:17 only matches ^#'. Surfaced because rspdlite's R/wrap.R uses this style.
  • Dirk reported a residual issue with namespace = "append" mode that wasn't reproducible against rspdlite (it has no @export/@import tags). Needs a different repro.

Parser (R/tags.R):
- Pre-tag content now splits across blank lines into title (para 1),
  description (para 2), details (para 3+), matching roxygen2 behavior.
  Previously everything past the first blank line was jammed into description.
- Paragraph breaks inside details are preserved as paragraph separators.
- Drop a trailing empty details state when no content followed the blank line
  (e.g., a stray '#'' before '@param').

Package Rd generator (R/rd.R):
- Switch generate_package_rd to base-R Rd macros: \packageTitle{},
  \packageDescription{}, \packageAuthor{}, \packageMaintainer{}, and
  \packageIndices{}. DESCRIPTION is the source of truth.
- Hand-written paragraphs (now correctly parsed as details) land in \details{}.
- Drop the bespoke maintainer-from-DESCRIPTION helper - macros do this at
  help-render time.

Tested against eddelbuettel/rspdlite: man/formatter.Rd is byte-identical to
roxygen2's output except for the header comment; man/rspdlite-package.Rd
now correctly populates \details{} (was missing before) and delegates
title/description/author to DESCRIPTION via macros.
@eddelbuettel

Copy link
Copy Markdown
Collaborator

Dirk reported a residual issue with namespace = "append" mode that wasn't reproducible against rspdlite (it has no @export/@import tags). Needs a different repro.

I was sufficiently unclear, my bad. I ran my littler script trox.r, it just called document(). This nuked my existing (manual) NAMESPACE (but hey git saves our bacon,...). Running with document(namespace="none") as I should have in the first place did the job more nicely.

@TroyHernandez

Copy link
Copy Markdown
Contributor Author

There's a real UX question buried in this: default behavior of document() silently nuking a hand-edited NAMESPACE if you forget the flag. Possible follow-ups for another PR:

  • Detect-and-warn: if NAMESPACE exists and has no tinyrox header line, warn before overwriting.
  • Change default to "append": less destructive default. Existing tinyrox start/end markers protect the user's hand edits.

Neither is in scope for this PR. Just worth flagging.

@eddelbuettel

Copy link
Copy Markdown
Collaborator

Agree completely--it's an open question without a perfect answer. Maybe even a defensive posture is good: do not overwrite a NAMESPACE unless it as the tinyrox tag in it?

@TroyHernandez TroyHernandez merged commit 27c1587 into main May 19, 2026
4 checks passed
@TroyHernandez TroyHernandez deleted the fix-package-rd branch May 19, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants